import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils, MyUtils


def demo(publishPath,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx"):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
     stepIdxListNot = [0]

     publish = publishPath
     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)

def moduleBack():
    
    rootPath = 'E:/workspace/0_model/越南夏普/夏普模组/背面/'
    publishPath = rootPath  #不批量发布model
    name = "模组背面151-"
    dstProductsList=[
        
        #2线
            "型号12.0矩形有壳2",
            "型号12.2矩形有壳2",
                   
        #3线    
            "型号12.2异形有壳3",
            "型号16.3矩形有壳3",
            "型号16.3异形有壳3"
        ]


    #编辑参数####################################################
    srcProduct= "型号12.0矩形有壳2"
    commitInfo = "调整卡扣分数0.7"
    #publishPath = rootPath
    
    #编辑参数####################################################

    print(name)
    print("commitInfo: ", commitInfo)
    print("发布model：",publishPath)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct

    dstModelPathList = []
    for dstProducts in dstProductsList:
        dstModelPathList.append(rootPath+dstProducts+"/model-module-fan-"+dstProducts+"/")
    

    srcProductPath=rootPath+srcProduct+"/model-module-fan-"+srcProduct+"/"
    demo(publishPath=publishPath,srcProductPath=srcProductPath, 
        dstModelPathList=dstModelPathList,commitInfo=commitInfo)
    


if __name__ == "__main__":  

    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    moduleBack()
    exit(0)


    
